package com.desire.controller.purchase;

import com.desire.bean.common.PageBean;
import com.desire.bean.common.ResultBean;
import com.desire.bean.purchase.Provider;
import com.desire.controller.common.BaseController;
import com.desire.service.purchase.ProviderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author LittleDesire
 * @description
 * @date 2022-05-18 周三 11:58
 * @since 17
 */
@RestController
@Api(tags = "供应商管理")
@RequestMapping("/api/provider")
public class ProviderController extends BaseController {
    @Autowired
    ProviderService providerService;

    @PostMapping("/query")
    @ApiOperation(value = "查询供应商", notes = "返回数据分页信息")
    public ResultBean query(@RequestBody Map<String, Object> map) {
        PageBean query = providerService.query(map);
        return success(query);
    }

    @PostMapping("/save")
    @ApiOperation(value = "添加供应商", notes = "操作信息")
    public ResultBean save(@RequestBody @Valid Provider provider) {
        int rs = providerService.save(provider);
        return rs > 0 ? success("保存成功") : success("保存失败");
    }

}
